package com.yjc.drygoods.ware.controller;

import com.yjc.common.utils.PageUtils;
import com.yjc.common.utils.R;
import com.yjc.drygoods.ware.entity.SupplierSpuDetailEntity;
import com.yjc.drygoods.ware.service.SupplierSpuDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

/**
 * @author yjc
 * @create 2022-10-24 19:55
 */
@Slf4j
@RestController
@RequestMapping("ware/supplierspudetail")
public class SupplierSpuDetailController {
    @Autowired
    SupplierSpuDetailService supplierSpuDetailService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = supplierSpuDetailService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        SupplierSpuDetailEntity supplierSpuDetail = supplierSpuDetailService.getById(id);

        return R.ok().put("supplierSpuDetail", supplierSpuDetail);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SupplierSpuDetailEntity supplierSpuDetail) {
        supplierSpuDetailService.save(supplierSpuDetail);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SupplierSpuDetailEntity supplierSpuDetail) {
        supplierSpuDetailService.updateById(supplierSpuDetail);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        supplierSpuDetailService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }
}
